package pw.canyingisme.plugin.occupation;


import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import pw.canyingisme.plugin.config.ConfigLoader;
import pw.canyingisme.plugin.event.onAction;
import pw.canyingisme.plugin.event.onPlaceholderRequest;

public class OccupationPlaceholder extends PlaceholderExpansion {
    public String onRequest(OfflinePlayer player, String identifier){
        if(identifier.equals("player_occupation")){
            if(ConfigLoader.hasOccupation(player.getName())){
                return ConfigLoader.occupationGetName(ConfigLoader.getPlayerOccupation(player.getName()));
            }
            return "";
        }
        onPlaceholderRequest event = new onPlaceholderRequest(player,identifier);
        Bukkit.getServer().getPluginManager().callEvent(event);
        return null;
    }
    @Override
    public String getIdentifier() {
        return "occupation";
    }

    @Override
    public String getAuthor() {
        return "CanYingisme";
    }

    @Override
    public String getVersion() {
        return "0.0.1";
    }
    @Override
    public boolean canRegister(){
        return true;
    }
}
